package com.ypbase.cloud.tags.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ypbase.cloud.tags.api.dto.TagCategoryDto;
import com.ypbase.cloud.tags.common.util.ObjectConversion;
import com.ypbase.cloud.tags.dao.ITagCategoryDao;
import com.ypbase.cloud.tags.entity.TagCategory;
import com.ypbase.cloud.tags.service.ITagCategoryService;

@Service
public class TagCategoryServiceImpl implements ITagCategoryService {

	@Autowired
	private ITagCategoryDao tagCategoryDao;

	/**
	 * 根据园区编号查询所有分类
	 */
	@Override
	public List<TagCategoryDto> geTagCategoryList(TagCategory tagCategory) {
		List<TagCategory> listTag = tagCategoryDao.findSampleViaBatis(tagCategory);
		return ObjectConversion.copy(listTag, TagCategoryDto.class);
	}

	/***
	 * 添加分类
	 *
	 */
	@Override
	public TagCategoryDto addTagCategory(TagCategory tagCategory) {
		return ObjectConversion.copy(tagCategoryDao.save(tagCategory), TagCategoryDto.class);
	}

	/**
	 * 删除标签分类(逻辑删除)
	 */
	@Override
	public void deleteTagCategory(Long companyId) {
		TagCategory modelCategory = tagCategoryDao.getViaBatis(companyId);
		tagCategoryDao.deleteLogic(modelCategory);
	}
}
